﻿#ifndef __COMMH_CLASS_H__
#define __COMMH_CLASS_H__

#include "commerrno.h"
#include "CTArray.h"
#include "CTRandomNum.h"
#include "CTCodeConvert.h"
#include "CTCodeConvert2.h"

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace CTLib;

enum enumSystemMaxData
{
    COMM_MOD            = 1000,             //千分位
    EMAX_STRING_KEY_LEN = 64,               //最大的字符串KEY长度，用于数据更新
    MIN_ROLENAME_LEN = 4,                   //最少昵称字节数
    MAX_ROLENAME_LEN = 12,                  //最大昵称字节数

    //!!!注意 因为这里刚好ROLE_NAME_LEN USER_TOKEN_LEN 刚好相等 所以 mainctrl.h 中namespace __gnu_cxx只定义了一个
    ROLE_NAME_LEN = 64,                     //昵称：6个汉字(UTF8)+@+大区ID（10个数字）
    USER_TOKEN_LEN = 64,                    //用户标识长度.
	TENCENT_OPENID_LEN = 64,                //腾讯OPENID长度.
    MAX_ROLE_LEVEL = 300,                   //游戏生命允许的最大用户等级
    OPEN_ROLE_LEVEL = 100,                  //当前开放的最大用户等级
    DATA_RESET_SEC_OF_DAY = 0,              //数据重置时间
    USER_PASSWORD_LEN = 64,                 //用户密码长度
	MAX_ITEM_ICON_STR_LEN = 20,	            //图标名的字符串长度
	MAX_ITEM_DESC_STR_SIZE = 64,		    //商品描述字符串长度
	MAX_PLATFORM_STR_LEN = 64,	            //平台标识字符串长度

    MAX_ZONE_COUNT = 255,                   //游戏不做分服逻辑 在DBSvr做分区逻辑 此为分区最大值
    MAX_USER_PER_ZONE = 72057594037927935,  // GID 高8位表示大区ID 低56位表示大区下自增角色ID

#ifdef _DEBUG
    MAX_PLAYER_ONLINE           = 400,
    MAX_REGISTER_PLAYER         = 2000,
    MAX_PLAYER_DBINFO_COUNT     = 400,
    ENM_BATTLE_MATCH_UNIT       = 10,       //等待匹配队列
    ENM_BATTLE_ROOM_NUM         = 20,       //战斗房间数量
    ENM_BATTLE_VIDEO_NUM        = 20,       //录像缓存数量
#else
    MAX_PLAYER_ONLINE           = 30000,
    MAX_REGISTER_PLAYER         = 50000,
    MAX_PLAYER_DBINFO_COUNT     = 10000,
    ENM_BATTLE_MATCH_UNIT       = 100,     //等待匹配队列
    ENM_BATTLE_ROOM_NUM         = 8000,    //战斗房间数量
    ENM_BATTLE_VIDEO_NUM        = 2000,    //录像缓存数量
#endif

    MAX_CARD_CONFIG_COUNT   = 1024,     //卡牌配置条目总数
    MAX_STATUS_CONFIG_COUNT = 500,      //状态配置条目总数

    MAX_ROLE_CONFIG_COUNT   = 100,      //角色经验配置条目总数

    MAX_GM_ANS_STRING_BUFF  = 10240,    //GM应答数据长度

    MAX_OSS_ITEM_STRING_LEN = 2048,     //OSS账单物品字符串长度

    MAX_DROP_ITEM_PER_TIME  = 30,       //一次掉落物品的最大种类数

	MAX_HERO_CONFIG_COUNT   = 16,       //英雄配置条目总数
	MAX_ROLE_OPEN_HERO		= 10,       //当前开放的英雄ID
	MAX_HERO_BAT_RESULT_SAVED  = 5,     //保存最后的战斗结果
	MAX_ROLE_BAT_RESULT_SAVED  = 5,     //保存最后的战斗结果

	MAX_ROLE_OWN_HERO       = 16,       //玩家最多可拥有的英雄数

	MAX_FRIEND_COUNT        = 100,      //最大好友数量

	MAX_ACCOUNT_CONFIG_COUNT   = 500,   //帐号配置条目总数

	MAX_OFFLINE_FRIEND_MSG_COUNT = 10, //最大的离线好友消息数据

    MAX_SEN_WORD_LINE_LENGTH = 10240, //敏感词一行长度
    MAX_SEN_WORD_UTF8_LENGTH = MAX_SEN_WORD_LINE_LENGTH * 4, //敏感词一行长度

	//登录奖励
	MAX_LOGIN_REWARD_DAY_COUNT = 7,  //登录天数
	MAX_LOGIN_REWARD_ITEM_COUNT = 7, //奖励数量

    //活动相关
    MAX_ACT_CONFIG_COUNT = 200,  //活动配置表条目总数量

	//物品表配置
	MAX_ITEM_CONFIG_COUNT = 200,  //物品表配置总数量

    MAX_DAILY_TASK_CONFIG	= 3,     //任务队列
    MAX_DAILY_CYCLE_TASK_CONFIG = 1,
    MAX_ONCE_TASK_CONFIG = 	100,

    MAX_VIP_TASK_COUNT_CONFIG = 1,

    MAX_QUALIFYING_RANK_COUNT = 3000, //最大的排位赛排名人数
    MAX_QUALIFYING_RANK_REWARD_COUNT = 100, //只奖励前100名
};

enum EnumGrowthFund
{
	ENUM_GROWTH_FUND_STATUS_NOT_YET_PURCHASED = 0,
	ENUM_GROWTH_FUND_STATUS_PURCHASED = 1,
	ENUM_GROWTH_FUND_STATUS_FINISH_RECEIVE_AWARDS = 2,

	ENUM_GROWTH_FUND_DATA_STATUS_CAN_NOT_RECEIVE = 0,

	ENUM_GROWTH_FUND_DATA_STATUS_CAN_RECEIVE = 1,

	ENUM_GROWTH_FUND_DATA_STATUS_RECEIVE = 2,

	MAX_GROWTH_FUND_DATA_COUNT = 10,
};

enum EnmVipID
{
	ENUM_SILVER_VIP_ID = 1,
	ENUM_GOLD_VIP_ID = 2,
	ENUM_FUCK_VIP_ID = 3,

	ENUM_VIP_STATUS_VIP = 0, //一般状态
	ENUM_VIP_STATUS_LAST_THREE_DAYS = 1, //最后3天
	ENUM_VIP_STATUS_NOTIFY_LAST_THREE_DAYAS = 2, //通知最后3天
	ENUM_VIP_STATUS_EXPIRED = 2, //过期状态
	ENUM_VIP_STATUS_NOTIFY_EXPIRED = 3, ///通知过期状态
};

enum EnmCardMacro
{
	ENM_MAX_OWN_CARD		=	MAX_CARD_CONFIG_COUNT,		//可拥有不同类型卡片的最多数
};

enum EnmBattleDeckType
{
	ENUM_BATTLE_DECK_TYPE_BASE = 1, //基本模式
	ENUM_BATTLE_DECK_TYPE_CUSTOM = 2, //自定义模式
};

enum EnmCardAttrMacro
{
	CARD_ATTR_NEW	  = 1,   //未被浏览过
	CARD_ATTR_NOTIFY  = 2,   //还未通知过
};

enum EnmHeroAttrMacro
{
	HERO_ATTR_NOTIFY  = 1,   //还未通知过
	HERO_ATTR_BATTLE  = 2,   //战斗结算解锁
};

enum EnmCardRaceMacro
{
    ENM_CARD_RACE_NULL = 0,     //无种族
    ENM_CARD_RACE_WORM = 1,     //虫怪
    ENM_CARD_RACE_GHOST = 2,    //鬼族
    ENM_CARD_RACE_SEA = 3,      //海族
    ENM_CARD_RACE_TREE = 4,     //树妖
};

enum EnmDeckMacro
{
	ENM_MAX_OWN_DECK			=  12,			//最多可拥有的套牌数
	ENM_MAX_CARD_IN_DECK		=  30,			//套牌中最多可拥有的卡牌数
	ENM_MAX_DECK_NAME_STR		=  64,			//套牌名称长度
};

enum EnmBattleMacro
{
    ENM_BATTLE_CAMP_ROLE_NUM    = 3,                            //战斗单方人数 //此值变更CBattleInf中相应变更 限制最多5vs5
    ENM_BATTLE_ROOM_ROLE_NUM    = ENM_BATTLE_CAMP_ROLE_NUM * 2, //战斗双方总数 //此值变更CBattleInf中相应变更 限制最多5vs5
    ENM_BATTLE_OPEN_ROLE_NUM    = 2,                            //当前开放总数
    ENM_BATTLE_FIRST_TURN_CARD_NUM  = 3,    //先手卡牌数量
    ENM_BATTLE_OTHER_TURN_CARD_NUM  = 4,    //后手卡牌数量
    ENM_BATTLE_ACT_START_OVER   = 30,       //进入房间Ready等待时间
    ENM_BATTLE_PREPARE_TIME     = 120,      //选牌准备阶段时长
    ENM_BATTLE_TURN_OVER_TIME   = 420,      //每回合战斗时间
    ENM_BATTLE_IDLE_OVER_TIME   = 15,       //发呆者每回合战斗时间

    ENM_BATTLE_CARD_HAND_NUM    = 10,       //单方手牌总数量
    ENM_BATTLE_CARD_BANK_NUM    = 30,       //单方卡牌库数量
    ENM_BATTLE_CARD_COUNT_NUM   = 40,       //单方使用卡牌统计数量
    ENM_BATTLE_CARD_PLAY_NUM    = 7,        //单方场上卡牌数
    ENM_BATTLE_CARD_SPEC_NUM    = 3,        //英雄牌 技能牌 法宝牌
    ENM_BATTLE_CARD_ARCANE_NUM  = 5,        //秘法牌
    ENM_BATTLE_HERO_MAX_HP      = 30,       //英雄最大血量
    ENM_BATTLE_HERO_INIT_HP     = 30,       //英雄初始血量
    ENM_BATTLE_HERO_MAX_MP      = 10,       //英雄最大法力
    ENM_BATTLE_HERO_INIT_MP     = 7,        //英雄初始法力

    ENM_BATTLE_CARD_ID_MOD_CONF = 10000,    //单场战斗卡牌ID = 卡牌配置ID*10000 + (房间角色数组下标*1000) + 卡牌偏移
    ENM_BATTLE_CARD_ID_MOD_ROLE = 1000,     //单场战斗卡牌ID = 卡牌配置ID*10000 + (房间角色数组下标*1000) + 卡牌偏移
    ENM_BATTLE_ROOM_ROLE_INDEX  = 9,        //因为用于生成卡牌ID 这里限制每个房间最大角色数量 那么房间数组为10
    ENM_BATTLE_CARD_CONF_ID_MAX = 200000,   //因为int值21亿限制以及逻辑需要限制卡牌配置ID的最大值
    ENM_BATTLE_CARD_CONF_ID_MIN = 20,       //因为卡牌ID生成规则需要限制卡牌配置ID的最小值

    ENM_BATTLE_CARD_TARGET_MOD  = 10000,    //角色的英雄牌(技能牌,法宝牌)和场牌都可能成为目标
    ENM_BATTLE_CARD_TARGET_SPEC = 1,        //作为卡牌目标时特殊牌的类型
    ENM_BATTLE_CARD_TARGET_PLAY = 2,        //作为卡牌目标时场景牌的类型
    ENM_BATTLE_CARD_TARGET_HAND = 3,        //作为卡牌目标时手上牌的类型
    ENM_BATTLE_CARD_TARGET_ARCANE = 4,      //作为卡牌目标时秘法牌的类型

    ENM_BATTLE_EVENT_COUNT      = 32,       //战斗事件总数
    ENM_BATTLE_EVENT_ARGU_COUNT = 10,       //战斗事件参数数量
    ENM_BATTLE_STATUS_COUNT     = 20,       //单人战斗状态总数
    ENM_BATTLE_RESPOND_COUNT    = 20,       //战斗响应分包条数
    ENM_BATTLE_TARGET_COUNT     = 24,       //战斗目标总数
    ENM_BATTLE_OBJECT_COUNT     = 16,       //战斗过程对象总数
    ENM_BATTLE_VIDEO_SIZE       = 1048576,  //录像单元大小

    ENM_BATTLE_STATUS_OVER_TURN = 2,        //持续性状态存在回合数 当前一方角色行动为一回合

    ENM_BATTLE_CARD_GROUP_BASIC = 1,        //套牌类型:基础套牌
    ENM_BATTLE_CARD_GROUP_CUSTOM = 2,       //套牌类型:自定义套牌

	ENM_BATTLE_RESULT_WIN   =  1,     //战胜
	ENM_BATTLE_RESULT_LOSE  = -1,     //战败
	ENM_BATTLE_RESULT_DRAW  =  0,     //战平
};

enum EnumArena
{
	ENUM_ARENA_CARD_COUNT = 30,
	ENUM_ARENA_SELECT_HERO = 3,
	ENUM_ARENA_SELECT_CARD  = 3,
	ENUM_ARENA_MAX_WIN_COUNT = 12,
	ENUM_ARENA_MAX_FAIL_COUNT = 3,
	ENUM_ARENA_MAX_REWARD_COUNT = 5,
	ENUM_ARENA_PAY_TYPE_SUB_QQ = 1, //使用QQ币付费
	ENUM_ARENA_PAY_TYPE_SUB_GOLD = 2, //使用元宝付费
	ENUM_ARENA_PAY_SUB_GOLD_COUNT = 150, //使用元宝付费扣除的元宝数
	ENUM_ARENA_PAY_SUB_QQ_COUNT = 120, //使用QQ币，付费扣除的QQ币数
};

enum EnumArenaStatus
{
	ENUM_ARENA_STATUS_NEED_PAY = 0,
	ENUM_ARENA_STATUS_ALREADY_PAY_AND_NO_SELECT_HERO = 1,
	ENUM_ARENA_STATUS_ALREADY_PAY_AND_NO_SELECT_CARD = 2,
	ENUM_ARENA_STATUS_ALREADY_PAY_AND_ALL_READY = 3,
	ENUM_ARENA_STATUS_CLEAR = 4, //竞技场结算,发放奖励
	ENUM_ARENA_STATUS_GET_REWARD = 5, //用户获取奖励
};

enum EnumOfflineFriendMsg
{
	ENUM_OFFLINE_FRIEND_MSG_ADD_FRIEND = 1, //邀请好友离线消息
};

enum EnumQualifying
{
	ENUM_QUALIFYING_MAX_LEVEL = 25, //排位赛最大等级数值,等级最低
	ENUM_QUALIFYING_MAX_REWARD_COUNT = 100, //排位赛最大的奖励人数
};

//英雄ID
enum EnumHeroId
{
	HERO_ID_WUKONG = 1,
	HERO_ID_BAJIE  = 2,
};

//用户任务系统的状态
enum EnmUserTaskStatus
{
	ENUM_USER_TASK_UNLOAD_CONFIG = 0, //还没有从配置表中载入
	ENUM_USER_TASK_LOAD_CONFIG = 1,   //已经从配置表中载入
	ENUM_USER_TASK_RELOAD_CONFIG = 2, //配置表被修改，重新载入
};

enum EnmCardTypeMacro
{
    //因为在card.xlsx用到了数值定义 这里的数值不能随意修改
    ENM_CARD_TYPE_MIN = 1,          //卡牌类型最小值
    ENM_CARD_TYPE_MINION = 1,       //侍从 相对以下而言也是 友方侍从
    ENM_CARD_TYPE_HERO = 2,         //英雄 相对以下而言也是 友方英雄
    ENM_CARD_TYPE_SKILL = 3,        //技能牌
    ENM_CARD_TYPE_MAGIC = 4,        //法宝牌
    ENM_CARD_TYPE_ARCANE = 5,       //秘法牌 相对以下而言也是 自己已挂载的秘法牌
    ENM_CARD_TYPE_MANA = 6,         //法术牌 相对以下而言也是 自己手牌中的法术牌
    ENM_CARD_TYPE_HAND = 7,         //手牌
    ENM_CARD_TYPE_MINION_LEFT = 8,  //侍从左边的牌
    ENM_CARD_TYPE_MINION_RIGHT = 9, //侍从右边的牌
    ENM_CARD_TYPE_FRIEND_ROLE = 10,     //友方角色
    ENM_CARD_TYPE_ENEMY_ROLE = 11,      //敌方角色
    ENM_CARD_TYPE_WHOLE_ROLE = 12,      //各方角色
    ENM_CARD_TYPE_ENEMY_MINION = 13,    //敌方侍从
    ENM_CARD_TYPE_WHOLE_MINION = 14,    //各方侍从
    ENM_CARD_TYPE_ENEMY_HERO = 15,      //敌方英雄
    ENM_CARD_TYPE_WHOLE_HERO = 16,      //各方英雄
    ENM_CARD_TYPE_MINION_LEFT_RIGHT = 17, //侍从左右两边的牌
    ENM_CARD_TYPE_CARD_BANK = 18,   //牌库中的牌
    ENM_CARD_TYPE_ENEMY_MANA = 19,  //敌方玩家手牌中的法术牌
    ENM_CARD_TYPE_WHOLE_MANA = 20,  //所有玩家手牌中的法术牌
    ENM_CARD_TYPE_HAND_ARCANE = 21,        //自己手牌中的秘法牌
    ENM_CARD_TYPE_ENEMY_HAND_ARCANE = 22,  //敌方玩家手牌中的秘法牌
    ENM_CARD_TYPE_WHOLE_HAND_ARCANE = 23,  //所有玩家手牌中的秘法牌
    ENM_CARD_TYPE_HAND_MINION = 24,        //自己手牌中的侍从牌
    ENM_CARD_TYPE_ENEMY_HAND_MINION = 25,  //敌方玩家手牌中的侍从牌
    ENM_CARD_TYPE_WHOLE_HAND_MINION = 26,  //所有玩家手牌中的侍从牌
    ENM_CARD_TYPE_RACE_MINION = 27,        //友方场上指定种族的侍从牌
    ENM_CARD_TYPE_ENEMY_RACE_MINION = 28,  //敌方玩家场上指定种族的侍从牌
    ENM_CARD_TYPE_WHOLE_RACE_MINION = 29,  //所有玩家场上指定种族的侍从牌
    ENM_CARD_TYPE_HAND_RACE_MINION = 30,        //自己手牌中指定种族的侍从牌
    ENM_CARD_TYPE_ENEMY_HAND_RACE_MINION = 31,  //敌方玩家手牌中指定种族的侍从牌
    ENM_CARD_TYPE_WHOLE_HAND_RACE_MINION = 32,  //所有玩家手牌中指定种族的侍从牌
    ENM_CARD_TYPE_HERO_HURT_VALUE = 33,     //己方英雄所受伤害值(防止递归 不能对血量值进行修正)
    ENM_CARD_TYPE_MAGIC_ATK_VALUE = 34,     //己方法宝具有的攻击力(防止递归 不能对攻击力进行修正)
    ENM_CARD_TYPE_MAX = 34,     //卡牌类型最大值
};

enum EnmCardAttrMap
{
    ENM_CARD_ATTR_MIN = 1,     //卡牌属性类型最小值
    ENM_CARD_ATTR_MP_MAX = 1,      //法力值最大值 只有英雄牌才有
    ENM_CARD_ATTR_MP_NOW = 2,      //法力值当前值 只有英雄牌才有
    ENM_CARD_ATTR_HP_MAX = 3,      //生命值最大值
    ENM_CARD_ATTR_HP_NOW = 4,      //生命值当前值
    ENM_CARD_ATTR_MANA_ATK = 5,    //法术伤害
    ENM_CARD_ATTR_ATK = 6,         //攻击力
    ENM_CARD_ATTR_COST = 8,        //法力耗费
    ENM_CARD_ATTR_ARMOR = 10,      //护甲值
    ENM_CARD_ATTR_ENDURE = 12,     //耐久度

    ENM_CARD_ATTR_COST_MAX = 7,    //法力耗费最大值 已废弃
    ENM_CARD_ATTR_ARMOR_MAX = 9,   //护甲值最大值 已废弃
    ENM_CARD_ATTR_ENDURE_MAX = 11, //耐久度最大值 已废弃

    ENM_CARD_ATTR_MAX  = 12,     //卡牌属性类型最大值
};

enum EnumTaskStatus
{
	ENUM_TASK_STATUS_NEW = 0,  //新任务，表示刚刚获得
	ENUM_TASK_STATUS_NORMAL = 1,  //正常状态
	ENUM_TASK_STATUS_MODIFY = 2,  //如果任务有进展，表示被修改了
	ENUM_TASK_STATUS_FINISHED = 3, //任务已经完成，但没有给与奖励
	ENUM_TASK_STATUS_REWARD = 4, //任务完成获得奖励
	ENUM_TASK_STATUS_NOTIFY_REWARD = 5, //获得奖励并通知前端
};

enum EnmCardColorMacro
{
	ENM_CARD_COLOR_NONE = 0,     //无效的卡牌颜色
	ENM_CARD_COLOR_MIN  = 1,     //卡牌颜色最小值
	ENM_CARD_COLOR_WHITE  = 1,
	ENM_CARD_COLOR_GREEN  = 2,
	ENM_CARD_COLOR_BLUE  = 3,
	ENM_CARD_COLOR_PURPLE  = 4,
	ENM_CARD_COLOR_GOLDEN  = 5,
	ENM_CARD_COLOR_MAX  = 5,     //卡牌颜色大值
};

enum EnmBattleCamp
{
    BATTLE_CAMP_NULL = 0,       //战斗无阵营
    BATTLE_CAMP_RED = 1,        //对战红方
    BATTLE_CAMP_BLUE = 2,       //对战蓝方
};

enum EnmBattleMode
{
    BATTLE_MODE_NULL = 0,       //
    BATTLE_MODE_CHALLENGE = 1,  //挑战模式
    BATTLE_MODE_FRIENDLY = 2,   //好友对战
    BATTLE_MODE_ARENA = 3,      //竞技场
    BATTLE_MODE_HIGH_LADDER = 4,//排位赛模式
    BATTLE_MODE_ARENA_OR_QUALIFYING = 5, //排位赛或竞技场
};

enum EnmSelectCount
{
    SELECT_PLAYER_BASE_BRIEF_COUNT_PER_TIME = 100,  //一次获取的记录条数 不能再扩大避免超过32KB
};

enum EnmZoneDataMacro
{
    T_ZONE_DATA_MASK_VALUE = 10000,
    T_ZONE_DATA_ID_MIN = 1,
    T_ZONE_DATA_ID_BASE = 1,
    T_ZONE_DATA_ID_DETAIL = 2,
    T_ZONE_DATA_ID_MAX = 2,
};

//物品的类型
enum ITEM_TYPE
{
	ITEM_TYPE_NULL = 0,         //无效的物品类型
	ITEM_TYPE_MIN = 1,

	ITEM_TYPE_EXP = 1,          //经验
	ITEM_TYPE_CARD_PACKET = 2,  //卡包
	ITEM_TYPE_CARD_UNLOCK = 3,  //解锁卡牌
	ITEM_TYPE_GOLD = 4,         //元宝
	ITEM_TYPE_CARD = 5,         //卡牌 区别于解锁卡牌 这个是数量上的增加
	ITEM_TYPE_HERO = 6,         //英雄
	ITEM_TYPE_CARD_SOUL = 7,	//卡魂

	ITEM_TYPE_MAX = 7,
};


//通知类型
enum NOTIFY_TYPE_TAG
{
    NOTIFY_ROLE_INFO = (0x1 << 0),
	NOTIFY_ROLE_CARD = (0x1 << 1),
	NOTIFY_QUALIFY_INFO = (0x1 << 2),
};

//平台登录来源
enum EnmPlatFormMacro
{
    PLATFORM_MACRO_UNKNOWN = 0,
    PLATFORM_MACRO_LOCAL = 1,
    PLATFORM_MACRO_BANSHU = 2,
    PLATFORM_MACRO_TENCENT_PENGYOU = 3,
    PLATFORM_MACRO_TENCENT_QZONE = 4,
};

enum VarObjectOpType_tag
{
    VOP_SELECT = 0,
    VOP_CREATE = 1,
    VOP_UPDATE = 2,
    VOP_DELETE = 3,
};

enum VarObjectDataType_tag
{
    DT_SWAPCOUNT = 0,
    DT_PLAYER_BASE_INFO = 1,
    DT_PLAYER_BASE_BRIEF = 2,
    DT_PLAYER_DETAIL_INFO = 3,
    DT_FLUSH_DBSVR_DATA = 4,            //通知DBSVR将数据刷入数据库，主要用于重启
    DT_ZONE_DATA = 5,                   //大区数据
    DT_ZONE_COUNT = 6,                  //大区记录数，启动时使用
    DT_USERTOKEN_TO_GID = 7,
    DT_OSS_PLAYER_DATA = 8,             //OSS用户数据
    DT_OSS_ZONE_DATA = 9,               //OSS大区数据
    DT_OSS_PLAYER_MONEY = 10,           //OSS用户金币\银币操作
};

//用户所处的状态
enum ENUM_USER_STATUS
{
    ENUM_USER_STATUS_BROWSE_THE_MAIN_INTERFACE = 1,
};

//OSS模块
enum EN_OSS_MODULE
{
	OSS_MODULE_LOGIN_REWARD     = 1,  //登录奖励
	OSS_MODULE_BATTLE_EXP       = 2,  //战斗增加经验
	OSS_MODULE_BATTLE_RESULT    = 3,  //战斗结果解锁卡牌
    OSS_MODULE_VIP              = 4,  //VIP
    OSS_MODULE_GM               = 5,  //GM命令
    OSS_MODULE_REGISTER         = 6,  //注册
    OSS_MODULE_ACT              = 7,  //活跃
    OSS_MODULE_PAY              = 8,  //充值
    OSS_MODULE_LOGIN            = 9,  //登录
    OSS_MODULE_LOGOUT           = 10, //登出
    OSS_MODULE_EXIT             = 11, //mainsvr停机
    OSS_MOUDLE_UPDATE           = 12, //OSS 更新
    OSS_COUNT_DAILYTASK         = 13, //日常任务激活
    OSS_GOLD_CARDBAG            = 14, //元宝购买卡包
    OSS_SILVER_CARD             = 15, //卡魂购买卡片
    OSS_CARDBAG_OPEN            = 16, //开卡包
    OSS_MOUDLE_ARENA            = 17, //竞技场
    OSS_MOUDLE_QUALIFYING       = 18, //排位赛
    OSS_MOUDLE_FRIEND           = 19, //友谊赛
    OSS_SELL_CARD               = 20, //出售卡片
    OSS_ONCE_TASK               = 21, //一次性任务
    OSS_DAILY_TASK              = 22, //日常任务
    OSS_CYCLE_TASK              = 23, //循环任务
    OSS_VIP_TASK                = 24, //VIP任务
    OSS_MOUDLE_GROWTHFUND       = 25, //成长基金
    OSS_MOUDLE_FIRSTRECHANG     = 26, //首充活动
    OSS_EXP_HERO                = 27, //等级增加解锁英雄
    OSS_HERO_CARD_UNLOCK        = 28, //英雄解锁后解锁卡牌
    OSS_HERO_CARDS              = 29, //英雄卡组
    OSS_CARD_UPGRADE            = 30, //卡牌升级
    OSS_MODULE_MATCH            = 31, //参赛情况
    OSS_HERO_EDIT               = 32, //英雄编辑情况
    OSS_MAIL_EXECL              = 33, //邮件配置奖励
};

enum EN_OSS_STATUS
{
    OSS_STATUS_COUNT            = 1,  //OSS统计
    OSS_STATUS_LOG              = 2,  //OSS日志记录
};

enum EN_OSS_ITEM_STATUS
{
    OSS_ITEM_SUB                = 0,  //物品消耗
    OSS_ITEM_ADD                = 1,  //物品产出
};

//////////////////////////////////////////////////////////////////////////


class CKeyValue : public CTCodeObject
{
public:
	CKeyValue()
	{
		Clear();
	}

	void Clear()
	{
		_iKey = 0;
		_iValue = 0;
	}

public:
	int _iKey;
	int _iValue;
};
BEGIN_CODE_CONVERT(CKeyValue)
CODE_CONVERT(_iKey)
CODE_CONVERT(_iValue)
END_CODE_CONVERT(CKeyValue)

class CVarObjectKey : public CTCodeObject
{
public:
    CVarObjectKey()
    {
        OBJ_CHECK_RELOAD();
        m_u64ID = 0;
        m_chDataType = 0;
        m_sStrID.Set("");
    }

    bool operator== (const CVarObjectKey & stKey) const
    {
        if(m_sStrID == stKey.m_sStrID && m_u64ID == stKey.m_u64ID && m_chDataType == stKey.m_chDataType)
        {
            return true;
        }

        return false;
    }

public:
    char m_chDataType;
    uint64 m_u64ID;
    CTSizeString<EMAX_STRING_KEY_LEN> m_sStrID;
};
BEGIN_CODE_CONVERT(CVarObjectKey)
CODE_CONVERT(m_chDataType)
CODE_CONVERT(m_u64ID)
CODE_CONVERT(m_sStrID)
END_CODE_CONVERT(CVarObjectKey)

//////////////////////////////////////////////////////////////////////////

//每日自动更新的数据
template<typename T>
class CDailyReflushData : public CTCodeObject
{
public:
    CDailyReflushData()
    {
        Clear ();
    }

    void Clear ()
    {
        _iLastUpdateTime = 0;
        _stDefaultData = 0;
        _stData = 0;
    }

    void SetDefault(T stData)
    {
        _stDefaultData = stData;
    }

    T Get(int iNowTime, int iTimeOffset = DATA_RESET_SEC_OF_DAY)
    {
        if (!CTTimeUtils::IsSameDay(_iLastUpdateTime, iNowTime, iTimeOffset))
        {
            return _stDefaultData;
        }

        return _stData;
    }

    bool IsSameDay(int iNowTime, int iTimeOffset = DATA_RESET_SEC_OF_DAY)
    {
        return CTTimeUtils::IsSameDay(_iLastUpdateTime, iNowTime, iTimeOffset);
    }

    bool IsYesterday(int iNowTime, int iTimeOffset = DATA_RESET_SEC_OF_DAY)
    {
        return CTTimeUtils::IsSameDay(_iLastUpdateTime, iNowTime-86400, iTimeOffset);
    }

    bool IsTimeOut(int iNowTime, int iTimeDiff)
    {
        return (iNowTime - _iLastUpdateTime >= iTimeDiff) ? true : false;
    }

    T GetData()
    {
        return _stData;
    }

    void Add(T stCount, int iNowTime, int iTimeOffset = DATA_RESET_SEC_OF_DAY)
    {
        _stData = Get(iNowTime, iTimeOffset);
        _stData += stCount;
        _iLastUpdateTime = iNowTime;
    }

    void Sub(T stCount, int iNowTime, int iTimeOffset = DATA_RESET_SEC_OF_DAY)
    {
        _stData = Get(iNowTime, iTimeOffset);
        _stData -= stCount;
        _iLastUpdateTime = iNowTime;
    }

    void Set(T stCount, int iNowTime)
    {
        _stData = stCount;
        _iLastUpdateTime = iNowTime;
    }

public:
    T _stDefaultData;       //缺省值，不入库

    int _iLastUpdateTime;
    T _stData;
};

typedef CDailyReflushData<char> CDailyReflushChar;
BEGIN_CODE_CONVERT(CDailyReflushChar)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushChar)

typedef CDailyReflushData<unsigned char> CDailyReflushUChar;
BEGIN_CODE_CONVERT(CDailyReflushUChar)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushUChar)

typedef CDailyReflushData<short> CDailyReflushShort;
BEGIN_CODE_CONVERT(CDailyReflushShort)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushShort)

typedef CDailyReflushData<unsigned short> CDailyReflushUShort;
BEGIN_CODE_CONVERT(CDailyReflushUShort)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushUShort)

typedef CDailyReflushData<int> CDailyReflushInt;
BEGIN_CODE_CONVERT(CDailyReflushInt)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushInt)

typedef CDailyReflushData<unsigned int> CDailyReflushUInt;
BEGIN_CODE_CONVERT(CDailyReflushUInt)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushUInt)

typedef CDailyReflushData<int64> CDailyReflushInt64;
BEGIN_CODE_CONVERT(CDailyReflushInt64)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushInt64)

typedef CDailyReflushData<uint64> CDailyReflushUInt64;
BEGIN_CODE_CONVERT(CDailyReflushUInt64)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CDailyReflushUInt64)

//每月自动更新的数据 当前暂时不支持偏移 以0点为结算
template<typename T>
class CMonthlyReflushData : public CTCodeObject
{
public:
    CMonthlyReflushData()
    {
        Clear ();
    }

    void Clear ()
    {
        _iLastUpdateTime = 0;
        _stDefaultData = 0;
        _stData = 0;
    }

    void SetDefault(T stData)
    {
        _stDefaultData = stData;
    }

    T Get(int iNowTime)
    {
        if (!CTTimeUtils::IsSameMonth(_iLastUpdateTime, iNowTime))
        {
            return _stDefaultData;
        }

        return _stData;
    }

    void Add(T stCount, int iNowTime)
    {
        _stData = Get(iNowTime);
        _stData += stCount;
        _iLastUpdateTime = iNowTime;
    }

    void Sub(T stCount, int iNowTime)
    {
        _stData = Get(iNowTime);
        _stData -= stCount;
        _iLastUpdateTime = iNowTime;
    }

    void Set(T stCount, int iNowTime)
    {
        _stData = stCount;
        _iLastUpdateTime = iNowTime;
    }

public:
    T _stDefaultData;       //缺省值，不入库

    int _iLastUpdateTime;
    T _stData;
};

typedef CMonthlyReflushData<int> CMonthlyReflushInt;
BEGIN_CODE_CONVERT(CMonthlyReflushInt)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_stData)
END_CODE_CONVERT(CMonthlyReflushInt)

//带随机功能的数组扩展
template<typename T, int COUNT>
class CTRandArray : public CTArray<T,COUNT>
{
public:
    CTRandArray()
    {
    }

    virtual ~CTRandArray()
    {
    }

#define NUM_LONG_LONG_BIT 64

    void SetBit(int64& i64Array, int iIndex)
    {
        if (iIndex < 0 || iIndex >= NUM_LONG_LONG_BIT || CTArray<T,COUNT>::Size() > NUM_LONG_LONG_BIT)
        {
            return;
        }

        int64 i64Tmp = 1;
        i64Array |= (i64Tmp << iIndex);
    }

    bool GetBit(int64& i64Array, int iIndex)
    {
        if (iIndex < 0 || iIndex >= NUM_LONG_LONG_BIT || CTArray<T,COUNT>::Size() > NUM_LONG_LONG_BIT)
        {
            return false;
        }

        int64 i64Tmp = 1;
        return (i64Array & (i64Tmp << iIndex));
    }

#define RAND_COMM_MOD 1000

    void Random()
    {
        T stTemp;
        int iIndex = 0;
        int64 i64Array = 0;
        for (int i = CTArray<T,COUNT>::Size() - 1; i >= 0; --i)
        {
            if (i > 0)
            {
                if (i > 1 && GetBit(i64Array, i))
                {
                    iIndex = CT_RANDOM_NUM->GetRand(RAND_COMM_MOD) % (i + 1);
                }
                else
                {
                    iIndex = CT_RANDOM_NUM->GetRand(RAND_COMM_MOD) % i;
                }

                stTemp = CTArray<T,COUNT>::m_astData[i];
                CTArray<T,COUNT>::m_astData[i] = CTArray<T,COUNT>::m_astData[iIndex];
                CTArray<T,COUNT>::m_astData[iIndex] = stTemp;
                SetBit(i64Array, iIndex);
            }
        }
    }
};

//带排序功能的数组扩展
template<typename T, int COUNT>
class CTRankArray : public CTArray<T,COUNT>, public CTCodeObject
{
public:
    CTRankArray()
    {
    }

    virtual ~CTRankArray()
    {
    }

    virtual bool IsSame(T&, T&) const
    {
        return false;
    }

    // a > b, 返回大于0,　　a < b, 返回小于0
    virtual int CmpFunc(T & a, T & b) const
    {
        return 0;
    }

	/*
	更新以CTArray为基础的排名榜 支持数值正负变化
    声明一个CTRankArray实例时候需要在cpp文件中实现IsSame和CmpFunc
    iOld 表示更新前的排名 iNew 表示更新后的排名 都从0开始 -1表示不在榜中
	返回值：0
	*/
    int Update(T& t, int& iOld, int& iNew)
    {
        //支持数值正负变化后的更新

        bool bAdd = true;
        bool bSwap = false;

        iOld = -1;
        iNew = -1;

        T stSwap = t;
        T stTemp = t;

        for (int i = 0; i < CTArray<T,COUNT>::Size(); ++i)
        {
            if ((!bSwap && CmpFunc(stSwap, CTArray<T,COUNT>::m_astData[i]) > 0) ||
                (bSwap && CmpFunc(stSwap, CTArray<T,COUNT>::m_astData[i]) >= 0))
            {
                if (bSwap)
                {
                    if (IsSame(t, CTArray<T,COUNT>::m_astData[i]))//单元已在榜中但排名变前
                    {
                        bAdd = false;
                        iOld = i;
                        CTArray<T,COUNT>::m_astData[i] = stSwap;
                        break;
                    }
                    else
                    {
                        stTemp = CTArray<T,COUNT>::m_astData[i];
                        CTArray<T,COUNT>::m_astData[i] = stSwap;
                        stSwap = stTemp;
                    }
                }
                else
                {
                    if (IsSame(t, CTArray<T,COUNT>::m_astData[i]))//单元已在榜中但排名没变
                    {
                        bAdd = false;
                        iOld = i;
                        iNew = i;
                        CTArray<T,COUNT>::m_astData[i] = stSwap;
                        break;
                    }
                    else
                    {
                        bSwap = true;
                        iNew = i;
                        stTemp = CTArray<T,COUNT>::m_astData[i];
                        CTArray<T,COUNT>::m_astData[i] = stSwap;
                        stSwap = stTemp;
                    }
                }
            }
            else if (IsSame(t, CTArray<T,COUNT>::m_astData[i]))//单元已在榜中但排名变后
            {
                bAdd = false;
                iOld = i;
                CTArray<T,COUNT>::m_astData[i] = stSwap;

                for ( ; i + 1 < CTArray<T,COUNT>::Size(); ++i)
                {
                    if (CmpFunc(CTArray<T,COUNT>::m_astData[i], CTArray<T,COUNT>::m_astData[i+1]) < 0)
                    {
                        stTemp = CTArray<T,COUNT>::m_astData[i];
                        CTArray<T,COUNT>::m_astData[i] = CTArray<T,COUNT>::m_astData[i+1];
                        CTArray<T,COUNT>::m_astData[i+1] = stTemp;
                        iNew = i + 1;
                    }
                    else
                    {
                        break;
                    }
                }
    
                break;
            }
        }
    
        if (bAdd && CTArray<T,COUNT>::Size() < CTArray<T,COUNT>::GetCount())
        {
            if (iNew >= 0)
            {
                CTArray<T,COUNT>::AddOneItem(stSwap);
            }
            else
            {
                iNew = CTArray<T,COUNT>::AddOneItem(stSwap);
            }
        }
    
        return 0;
    }

    int Update(T& t)
    {
        int iTmp = 0;
        return Update(t, iTmp, iTmp);
    }
};

class CDropItemData : public CTCodeObject
{
public:
    CDropItemData()
        :_ucItemType(0), _usItemConfigID(0), _iItemCount(0)
    {
    }

    void Clear ()
    {
        _ucItemType = 0;
        _usItemConfigID = 0;
        _iItemCount = 0;
    }

    bool operator == (const CDropItemData & stItem)
    {
        if (_ucItemType == stItem._ucItemType
            && _usItemConfigID == stItem._usItemConfigID
            && _iItemCount == stItem._iItemCount)
        {
            return true;
        }

        return false;
    }

    virtual ~CDropItemData()
    {
    }

public:
    unsigned char   _ucItemType;
    unsigned short  _usItemConfigID;
    int             _iItemCount;
};

BEGIN_CODE_CONVERT(CDropItemData)
CODE_CONVERT(_ucItemType)
CODE_CONVERT(_usItemConfigID)
CODE_CONVERT(_iItemCount)
END_CODE_CONVERT(CDropItemData)

/////////////////////////////////////////////////////////////////////////
class CPlayerBriefInfo : public CTCodeObject
{
public:
    CPlayerBriefInfo()
    {
        Clear();
    }

    void Clear()
    {
        _u64GID = 0;
        _sRoleName.Set("");
        _sUserToken.Set("");
    }

public:
    uint64                          _u64GID;        //角色唯一ID
    CTSizeString<ROLE_NAME_LEN>     _sRoleName;     //角色昵称
    CTSizeString<USER_TOKEN_LEN>    _sUserToken;    //帐号标识符
};

BEGIN_CODE_CONVERT(CPlayerBriefInfo)
CODE_CONVERT(_u64GID)
CODE_CONVERT(_sRoleName)
CODE_CONVERT(_sUserToken)
END_CODE_CONVERT(CPlayerBriefInfo)

typedef CTLib::CTArray<CPlayerBriefInfo, SELECT_PLAYER_BASE_BRIEF_COUNT_PER_TIME> T_BRIEF_ARRAY;

class CSingleCardData : public CTCodeObject
{
public:
	CSingleCardData()
	{
		Clear();
	}

	void Clear()
	{
		_uiCardId = 0;
		_iCardCnt = 0;
		_uiCardAttr = 0;
	}

	unsigned int GetCardId() const { return _uiCardId; }
	int GetCardCnt() const { return _iCardCnt; }
	unsigned int GetCardAttr() const { return _uiCardAttr; }

	void SetCardId(unsigned int id) { _uiCardId = id; }
	void SetCardCnt(int cnt) { _iCardCnt = cnt; }
	void SetCardAttr(unsigned int ca) { _uiCardAttr = ca; }

	unsigned int _uiCardId; 
	int _iCardCnt;
	unsigned int _uiCardAttr;
};
BEGIN_CODE_CONVERT(CSingleCardData)
CODE_CONVERT(_uiCardId)
CODE_CONVERT(_iCardCnt)
CODE_CONVERT(_uiCardAttr)
END_CODE_CONVERT(CSingleCardData)

class CSingleDeckData : public CTCodeObject
{
public:
	CSingleDeckData()
	{
		Clear();
	}

	void Clear()
	{
		_szDeckName.Set("");
		_auiDeckCards.Clear();

		_uiDeckId = 0;
		_uiHeroId = 0;
	}

	int Count(int cardId)
	{
		int cnt = 0;
		for(int i = 0; i < _auiDeckCards.Size(); i++)
		{
			if (cardId == (int)_auiDeckCards[i])
				cnt++;
		}
		return cnt;
	}

	int Replace(int oldID, int newID)
	{
		for(int i = 0; i < _auiDeckCards.Size(); i++)
		{
			if (oldID == (int)_auiDeckCards[i])
			{
				_auiDeckCards[i] = newID;
				return 0;
			}
		}
		return 1;
	}

	CTSizeString<ENM_MAX_DECK_NAME_STR>				_szDeckName; 
	CTArray<unsigned int, ENM_MAX_CARD_IN_DECK>		_auiDeckCards; 
	unsigned int _uiDeckId;
	unsigned int _uiHeroId;	
};
BEGIN_CODE_CONVERT(CSingleDeckData)
CODE_CONVERT(_szDeckName)
CODE_CONVERT(_auiDeckCards)	
CODE_CONVERT(_uiDeckId)
CODE_CONVERT(_uiHeroId)
END_CODE_CONVERT(CSingleDeckData)

class CSingleHeroData : public CTCodeObject
{
public:
	CSingleHeroData()
	{
		Clear();
	}

	void Clear()
	{
		_uiHeroId = 0;
		_uiWinRounds = 0;
		_uiHeroAttr = 0;
		_acBatResult.Clear();
	}

    int AddHeroBatResult(int iResult)
    {
		if (iResult != ENM_BATTLE_RESULT_DRAW
			&& iResult != ENM_BATTLE_RESULT_WIN
			&& iResult != ENM_BATTLE_RESULT_LOSE)
		{
			return ERROR_BATTLE_RESULT;
		}

        if (ENM_BATTLE_RESULT_WIN == iResult)
        {
            _uiWinRounds += 1;
        }

		if (_acBatResult.Size() >= _acBatResult.GetCount())
		{
			_acBatResult.ShiftDelOneItem(0);
		}
		
		_acBatResult.AddOneItem(iResult);

        return 0;
    }

public:
	unsigned int _uiHeroId;
	unsigned int _uiWinRounds;
	unsigned int _uiHeroAttr;
	CTArray<char, MAX_HERO_BAT_RESULT_SAVED> _acBatResult;
};
BEGIN_CODE_CONVERT(CSingleHeroData)
CODE_CONVERT(_uiHeroId)
CODE_CONVERT(_uiWinRounds)
CODE_CONVERT(_uiHeroAttr)
CODE_CONVERT(_acBatResult)
END_CODE_CONVERT(CSingleHeroData)

class CPlayerHeroData : public CTCodeObject
{
public:
	CPlayerHeroData()
	{
		Clear();
	}

	void Clear()
	{
		_astHeroList.Clear();
        _acRoleBattle.Clear();
	}

	static bool IsValidHeroId(unsigned int uiHeroId)
	{
		return (uiHeroId <= MAX_ROLE_OPEN_HERO && uiHeroId > 0);
	}

	int AddHero(unsigned int uiHeroId, bool bBattleAdd)
	{
		if (false == IsValidHeroId(uiHeroId))
		{
			return ERROR_ROLE_HERO_ID_WRONG;
		}

		for (int i = 0; i < _astHeroList.Size(); ++i)
		{
			if (_astHeroList[i]._uiHeroId == uiHeroId)
			{
				return ERROR_HERO_REPEAT_ADD;
			}
		}
		
		CSingleHeroData stSingleHero;
		stSingleHero._uiHeroId = uiHeroId;		
		CT_BIT_SET(stSingleHero._uiHeroAttr, HERO_ATTR_NOTIFY);
        if (bBattleAdd){CT_BIT_SET(stSingleHero._uiHeroAttr, HERO_ATTR_BATTLE);}
		if (_astHeroList.AddOneItem(stSingleHero) < 0)
		{
			return ERROR_HERO_REACH_MAX;
		}

		return RET_OK;
	}

    int FindHeroData(unsigned int uiHeroId)
    {
		for (int i = 0; i < _astHeroList.Size(); ++i)
		{
			if (_astHeroList[i]._uiHeroId == uiHeroId)
            {
                return i;
            }
        }

        return -1; //因为返回的值作为下标 这里必须返回-1
    }

    CSingleHeroData& GetHeroData(int iIndex) {return _astHeroList[iIndex];}

    int AddRoleBatResult(int iResult)
    {
		if (iResult != ENM_BATTLE_RESULT_DRAW
			&& iResult != ENM_BATTLE_RESULT_WIN
			&& iResult != ENM_BATTLE_RESULT_LOSE)
		{
			return ERROR_BATTLE_RESULT;
		}

		if (_acRoleBattle.Size() >= _acRoleBattle.GetCount())
		{
			_acRoleBattle.ShiftDelOneItem(0);
		}
		
		_acRoleBattle.AddOneItem(iResult);

        return 0;
    }
	
	CTArray<CSingleHeroData, MAX_ROLE_OWN_HERO> _astHeroList;
    CTArray<char, MAX_ROLE_BAT_RESULT_SAVED> _acRoleBattle;
};

BEGIN_CODE_CONVERT(CPlayerHeroData)
CODE_CONVERT(_astHeroList)
CODE_CONVERT(_acRoleBattle)
END_CODE_CONVERT(CPlayerHeroData)

class CPlayerArenaData: public CTCodeObject
{
public:
	CPlayerArenaData()
	{
		Clear();
	}

	void Clear()
	{
		_iArenaStatus = ENUM_ARENA_STATUS_NEED_PAY;
		_aiCardList.Clear();
		_iHeroID = 0;
		_iFailedCount = 0;
		_iWinnedCount = 0;
		_aiSelectHero.Clear();
		_aiSelectCard.Clear();
		_aiReward.Clear();
	}
public:
	bool CheckIndex(int i) const
	{
		return i >= 0 && i < _aiCardList.Size();
	}

	int Size() const { return _aiCardList.Size(); }

	int Index(int i) const { return _aiCardList[i]; }

	bool IsFull() const { return _aiCardList.Size() == _aiCardList.GetCount(); }

	bool IsEmpty() const { return _aiCardList.Size() == 0; }
public:
	int Add(int cardID)
	{
		if (IsFull())
			return 1;

		_aiCardList.AddOneItem(cardID);
		return 0;
	}

	int Del(int cardID)
	{
		for(int i = 0; i < _aiCardList.Size(); i++)
		{
			if (cardID == _aiCardList[i])
			{
				_aiCardList.ShiftDelOneItem(i);
				return 0;
			}
		}
		return 1;
	}
public:
	int	     GetArenaStatus() const { return _iArenaStatus; }
	int     GetHeroID() const { return _iHeroID; }
	int     GetFailedCount() const { return _iFailedCount; }
	int     GetWinnedCount() const { return _iWinnedCount; }

	void SetArenaStatus(int status) { _iArenaStatus = status; }
	void SetHeroID(int id) { _iHeroID = id; }
	void SetFailedCount(int fc) { _iFailedCount = fc; }
	void SetWinnedCount(int wc) { _iWinnedCount = wc; }
public:
	int AddSelectHero(int heroID)
	{
		if (_aiSelectHero.Size() >= _aiSelectHero.GetCount())
			return 1;

		_aiSelectHero.AddOneItem(heroID);
		return 0;
	}

	int AddSelectCard(int cardID)
	{
		if (_aiSelectCard.Size() >= _aiSelectCard.GetCount())
			return 1;

		_aiSelectCard.AddOneItem(cardID);
		return 0;
	}

	int AddReward(int type, int id, int count)
	{
		if (_aiReward.Size() >= _aiReward.GetCount())
			return 1;

		CDropItemData item;
		item._ucItemType = type;
		item._usItemConfigID = id;
		item._iItemCount = count;


		_aiReward.AddOneItem(item);
		return 0;
	}

	int GetReward(int iIndex, int &type, int &id, int &count)
	{
		if (iIndex >= 0 && iIndex < _aiReward.Size())
		{
			type = _aiReward[iIndex]._ucItemType;
			id = _aiReward[iIndex]._usItemConfigID;
			count = _aiReward[iIndex]._iItemCount;
		}
		else
		{
			return 1;
		}
		return 0;
	}

	int GetRewardSize() const
	{
		return _aiReward.Size();
	}

	int ClearSelectCard()
	{
		_aiSelectCard.Clear();
		return 0;
	}

	bool IsExistSelectCard(int cardID)
	{
		for(int i = 0; i < _aiSelectCard.Size(); i++)
		{
			if (cardID == _aiSelectCard[i])
				return true;
		}
		return false;
	}
public:
	int						_iArenaStatus;    //竞技场状态
	CTArray<int, ENM_BATTLE_CARD_BANK_NUM> _aiCardList;		//竞技场card
	int						_iHeroID;				//选择的英雄
	int						_iFailedCount;			//本次竞技场失败的次数
	int						_iWinnedCount;		//本次竞技场获胜的次数

	CTArray<int, ENUM_ARENA_SELECT_HERO> _aiSelectHero; //被选择的英雄
	CTArray<int, ENUM_ARENA_SELECT_CARD> _aiSelectCard; //被选择的卡牌
	CTArray<CDropItemData, ENUM_ARENA_MAX_REWARD_COUNT> _aiReward; //奖励
};

BEGIN_CODE_CONVERT(CPlayerArenaData)
CODE_CONVERT(_iArenaStatus)
CODE_CONVERT(_aiCardList)
CODE_CONVERT(_iHeroID)
CODE_CONVERT(_iFailedCount)
CODE_CONVERT(_iWinnedCount)
CODE_CONVERT(_aiSelectHero)
CODE_CONVERT(_aiSelectCard)
CODE_CONVERT(_aiReward)
END_CODE_CONVERT(CPlayerArenaData)

class CPlayerArena : public CTCodeObject
{
public:
	CPlayerArena()
	{
		Clear();
	}

	void Clear()
	{
		_iArenaCount = 0;
		_iArenaWinnedCount = 0;
		_iArenaFailedCount = 0;
		_stPlayerArenaData.Clear();
	}
public:
	int   GetArenaCount() const { return _iArenaCount; }
	void SetArenaCount(int ac) {  _iArenaCount = ac; }

	int  GetArenaWinnedCount() const { return _iArenaWinnedCount; }
	void SetArenaWinnedCount(int awc) { _iArenaWinnedCount = awc; }

	int GetArenaFailedCount() const { return _iArenaFailedCount; }
	void SetArenaFailedCount(int afc) { _iArenaFailedCount = afc; }
public:

public:
	int						_iArenaCount;    //参加过得竞技场次数
	int						_iArenaWinnedCount; //参加过的竞技场总共获胜的次数
	int						_iArenaFailedCount;  //参加过的经济次总共失败的次数

	CPlayerArenaData _stPlayerArenaData; //一次竞技场中的数据
};

BEGIN_CODE_CONVERT(CPlayerArena)
CODE_CONVERT(_iArenaCount)
CODE_CONVERT(_iArenaWinnedCount)
CODE_CONVERT(_iArenaFailedCount)
CODE_CONVERT(_stPlayerArenaData)
END_CODE_CONVERT(CPlayerArena)

class CPlayerQualifyingData : public CTCodeObject
{
public:
	CPlayerQualifyingData()
	{
		Clear();
	}

	CPlayerQualifyingData(const CPlayerQualifyingData &data)
	{
		_u64GID = data._u64GID;
		_iIntegral = data._iIntegral;
	}

	void Clear()
	{
		_u64GID = 0;
		_iIntegral = 0;
	}

public:
	bool operator<(const CPlayerQualifyingData &data) const
	{
		return _iIntegral < data._iIntegral;
	}
public:
	uint64 GetGID() const { return _u64GID; }
	int      GetIntegral() const { return _iIntegral; }
public:
	void SetGID(uint64 gid) { _u64GID = gid; }
	void SetIntegral(int i) { _iIntegral = i; }
public:
	uint64 _u64GID;
	int      _iIntegral;
};
BEGIN_CODE_CONVERT(CPlayerQualifyingData)
CODE_CONVERT(_u64GID)
CODE_CONVERT(_iIntegral)
END_CODE_CONVERT(CPlayerQualifyingData)

class CZoneQualifyingData : public CTCodeObject
{
public:
	CZoneQualifyingData()
	{
		Clear();
	}

	void Clear()
	{
		_stQualifyingData.Clear();
	}

public:
	bool IsFull()
	{
		if (_stQualifyingData.Size() >= _stQualifyingData.GetCount())
			return true;

		return false;
	}
public:
	//返回变化的所有范围
	int Insert(const CPlayerQualifyingData &data, std::set<uint64> &vec)
	{
		int rank = GetRank(data);
		if (rank > 0)
		{
			return 1;
		}
		if (IsFull())
		{
			int index = lower_bound(data);
			if (index == 0)
			{
				return 1;
			}

			for(int i = 1; i < index; i++)
			{
				_stQualifyingData[i-1] = _stQualifyingData[i];
			}

			_stQualifyingData[index-1] = data;

			for(int i = 0; i < index; i++)
			{
				vec.insert(_stQualifyingData[i].GetGID());
			}
			return 0;
		}

		int index = lower_bound(data);

		_stQualifyingData.AddOneItem(data);

		for(int i = _stQualifyingData.Size()-2; i >= index; i--)
		{
			_stQualifyingData[i+1] = _stQualifyingData[i];
		}
		_stQualifyingData[index] = data;

		for(int i = index; i < _stQualifyingData.Size()-1; i++)
		{
			vec.insert(_stQualifyingData[i].GetGID());
		}

		return 0;
	}
private:
	//获得不小于这个值的第一个索引
	int lower_bound(const CPlayerQualifyingData &data) const
	{
		const CPlayerQualifyingData *iter =  std::lower_bound(_stQualifyingData.m_astData, _stQualifyingData.m_astData+_stQualifyingData.Size(), data);
		return iter - _stQualifyingData.m_astData;
	}

	//获得大于这个值的第一个索引
	int upper_bound(const CPlayerQualifyingData &data) const
	{
		const CPlayerQualifyingData *iter =  std::upper_bound(_stQualifyingData.m_astData, _stQualifyingData.m_astData+_stQualifyingData.Size(), data);
		return iter - _stQualifyingData.m_astData;
	}

	//获得这个值的索引，如果没有返回-1
	int equal_range(const CPlayerQualifyingData &data) const
	{
		std::pair<const CPlayerQualifyingData *, const CPlayerQualifyingData *> iters = std::equal_range(_stQualifyingData.m_astData, _stQualifyingData.m_astData+_stQualifyingData.Size(), data);
		while(iters.first != iters.second)
		{
			if (iters.first->GetGID() == data.GetGID())
			{
				return iters.first - _stQualifyingData.m_astData;
			}
			iters.first++;
		}
		return -1;
	}
public:
	//获得排名，如果没有返回-1
	int GetRank(const CPlayerQualifyingData &data) const
	{
		int index = equal_range(data);
		if (index == -1)
		{
			return -1;
		}

		return _stQualifyingData.Size() - index;
	}

	int GetRank(int gid, int integral) const
	{
		CPlayerQualifyingData data;
		data.SetGID(gid);
		data.SetIntegral(integral);
		int index = equal_range(data);
		if (index == -1)
		{
			return -1;
		}

		return _stQualifyingData.Size() - index;
	}
public:
	int UpdateAdd(const CPlayerQualifyingData &oldData, const CPlayerQualifyingData &newData, std::set<uint64> &vec)
	{
		if (newData.GetIntegral() <= oldData.GetIntegral())
		{
			return 1;
		}

		int oldIndex = equal_range(oldData);
		if (oldIndex < 0)
		{
			return 1;
		}

		int newIndex = lower_bound(newData);

		for(int i = oldIndex + 1; i < newIndex; i++)
		{
			_stQualifyingData[i-1] = _stQualifyingData[i];
		}

		_stQualifyingData[newIndex-1] = newData;

		for(int i = oldIndex; i < newIndex; i++)
		{
			vec.insert(_stQualifyingData[i].GetGID());
		}
		return 0;
	}

	int UpdateSub(const CPlayerQualifyingData &oldData, const CPlayerQualifyingData &newData, std::set<uint64> &vec)
	{
		if (newData.GetIntegral() >= oldData.GetIntegral())
		{
			return 1;
		}

		int oldIndex = equal_range(oldData);
		if (oldIndex < 0)
		{
			return 1;
		}

		int newIndex = upper_bound(newData);

		for(int i = oldIndex; i > newIndex; i--)
		{
			_stQualifyingData[i] = _stQualifyingData[i-1];
		}
		_stQualifyingData[newIndex] = newData;

		for(int i = newIndex; i <= oldIndex; i++)
		{
			vec.insert(_stQualifyingData[i].GetGID());
		}

		return 0;
	}

	void Print()
	{
		for(int i = 0; i < _stQualifyingData.Size(); i++)
		{
			std::cout << "gid = " << _stQualifyingData[i].GetGID() << " integral = " << _stQualifyingData[i].GetIntegral() << " rank = " << _stQualifyingData.Size() - i << std::endl;
		}
	}
public:
	int GetLastQualifyingRankSize() const { return _stLastQualifyingRank.Size(); }

	int FindLastQualifyingRank(uint64 gid) const
	{
		for(int i = 0; i < _stLastQualifyingRank.Size(); i++)
		{
			if (gid == _stLastQualifyingRank[i].GetGID())
			{
				return i;
			}
		}
		return -1;
	}

	CPlayerQualifyingData &GetLastQualifyingRank(int index)
	{
		return _stLastQualifyingRank[index];
	}
public:
	CTLib::CTArray<CPlayerQualifyingData, MAX_QUALIFYING_RANK_COUNT> _stQualifyingData;
	CTLib::CTArray<CPlayerQualifyingData, MAX_QUALIFYING_RANK_REWARD_COUNT> _stLastQualifyingRank; //上一个排位赛获奖名额
};
BEGIN_CODE_CONVERT(CZoneQualifyingData)
CODE_CONVERT(_stQualifyingData)
CODE_CONVERT(_stLastQualifyingRank)
END_CODE_CONVERT(CZoneQualifyingData)

enum EnumMailSystem
{
	MAX_PLAYER_MAIL_SYSTEM_MAIL_COUNT = 256, //用户的最多的邮件数
	MAX_PLAYER_MAIL_SYSTEM_RECORD_COUNT = 1000,
	ENUM_MAIL_SYSTEM_STATUS_UNREAD = 0, //没有读的邮件
	ENUM_MAIL_SYSTEM_STATUS_READ = 1, //已经读取

	ENUM_MAIL_SYSTEM_STATUS_UN_GET_REWARD = 0,
	ENUM_MAIL_SYSTEM_STATUS_GET_REWARD = 1, //获得奖励

	ENUM_MAIL_SYSTEM_ACTION_STATUS_QUALIFYING_REWARD = 1, //排位赛发放奖励

	ENUM_MAIL_SYSTEM_MAIL_TYPE_EXECL_SEND = 0, //邮件类型，由配置表发放
	ENUM_MAIL_SYSTEM_MAIL_TYPE_ACTION_SEND = 1, //邮件类型，有活动发放，比如排位赛
};

class CPlayerMailData : public CTCodeObject
{
public:
	CPlayerMailData()
	{
		Clear();
	}

	void Clear()
	{
		_iSender = 0;
		_iMailID = 0;
		_iStatus = ENUM_MAIL_SYSTEM_STATUS_UNREAD;
		_iMailType = ENUM_MAIL_SYSTEM_MAIL_TYPE_EXECL_SEND;
		_iRewardStatus = ENUM_MAIL_SYSTEM_STATUS_UN_GET_REWARD;
	}

	uint64 GetSender() const { return _iSender; }
	int GetMailID() const { return _iMailID; }
	int GetStatus() const { return _iStatus; }
	int GetMailType() const { return _iMailType; }
	int GetRewardStatus() const { return _iRewardStatus; }

	void SetMailID(int mail) { _iMailID = mail; }
	void SetSender(uint64 send) { _iSender = send; }
	void SetStatus(int st) { _iStatus = st; }
	void SetMailType(int mt) { _iMailType = mt; }
	void SetRewardStatus(int rs) { _iRewardStatus = rs; }
public:
	int 			_iMailID;         //这个邮件的ID
	uint64		_iSender;       //发送者，0 为系统
	int				_iStatus; 		//邮件所处的状态
	int 			_iMailType;   //0为普通的系统派发，针对所有用户，数据在execl配置表中，1为获得奖励派发，配置数据在DB中
	int				_iRewardStatus; //0没有领取，1已经领取
};
BEGIN_CODE_CONVERT(CPlayerMailData)
CODE_CONVERT(_iMailID)
CODE_CONVERT(_iSender)
CODE_CONVERT(_iStatus)
CODE_CONVERT(_iMailType)
CODE_CONVERT(_iRewardStatus)
END_CODE_CONVERT(CPlayerMailData)

class CPlayerMailSystem : public CTCodeObject
{
public:
	CPlayerMailSystem()
	{
		Clear();
	}

	void Clear()
	{
		_stMailData.Clear();
	}

	int AddData(const CPlayerMailData &data)
	{
		if (_stMailData.Size() < _stMailData.GetCount() && _stMailRecord.Size() < _stMailRecord.GetCount())
		{
			if (FindMailData(data.GetMailID()) < 0)
			{
				_stMailData.AddOneItem(data);
				return _stMailData.Size();
			}
		}
		return -1;
	}

	void DelMail(int index)
	{
		_stMailData.ShiftDelOneItem(index);
	}

	int AddRecord(int id)
	{
		if (_stMailRecord.Size() < _stMailRecord.GetCount())
		{
			if (FindMailRecord(id) < 0)
			{
				_stMailRecord.AddOneItem(id);
				return _stMailRecord.Size();
			}
		}
		return -1;
	}

	int FindMailData(int mailID)
	{
		for(int i = 0; i < _stMailData.Size(); i++)
		{
			if (mailID == _stMailData[i].GetMailID())
				return i;
		}
		return -1;
	}

	CPlayerMailData &GetMailData(int index)
	{
		return _stMailData[index];
	}

	int GetSize() const
	{
		return _stMailData.Size();
	}

	int FindMailRecord(int mailID)
	{
		for(int i = 0; i < _stMailRecord.Size(); i++)
		{
			if (mailID == _stMailRecord[i])
				return i;
		}
		return -1;
	}

	int GetMailRecord(int index)
	{
		return _stMailRecord[index];
	}

	int GetRecordSize() const
	{
		return _stMailRecord.Size();
	}

	void DelMailRecord(int index)
	{
		_stMailRecord.ShiftDelOneItem(index);
	}
public:
	CTArray<CPlayerMailData, MAX_PLAYER_MAIL_SYSTEM_MAIL_COUNT>	_stMailData;
	CTArray<int, MAX_PLAYER_MAIL_SYSTEM_RECORD_COUNT>	_stMailRecord;
};
BEGIN_CODE_CONVERT(CPlayerMailSystem)
CODE_CONVERT(_stMailData)
CODE_CONVERT(_stMailRecord)
END_CODE_CONVERT(CPlayerMailSystem)

class CZoneMailData : public CTCodeObject
{
public:
	CZoneMailData()
	{
		Clear();
	}

	void Clear()
	{
		_iSender = 0;
		_iMailID = 0;
		_iMailSystemType = 0;
		_iSendTime = 0;
		_iExpiryTime = 0;
	}

	uint64 GetSender() const { return _iSender; }
	int GetMailID() const { return _iMailID; }
	int GetSystemType() const { return _iMailSystemType; }
	int GetSendTime() const { return _iSendTime; }
	int GetExpiryTime() const { return _iExpiryTime; }

	void SetMailID(int mail) { _iMailID = mail; }
	void SetSender(uint64 send) { _iSender = send; }
	void SetSystemType(int st) { _iMailSystemType = st; }
	void SetSendTime(int st) { _iSendTime = st; }
	void SetExpiryTime(int et) { _iExpiryTime = et; }
public:
	int 			_iMailID;         //这个邮件的ID
	uint64		_iSender;       //发送者，0 为系统
	int				_iMailSystemType; 		//邮件系统类型,比如排位赛啊
	int				_iSendTime;
	int				_iExpiryTime;
};
BEGIN_CODE_CONVERT(CZoneMailData)
CODE_CONVERT(_iMailID)
CODE_CONVERT(_iSender)
CODE_CONVERT(_iMailSystemType)
CODE_CONVERT(_iSendTime)
CODE_CONVERT(_iExpiryTime)
END_CODE_CONVERT(CZoneMailData)

class CzoneMailSystem : public CTCodeObject
{
public:
	CzoneMailSystem()
	{
		Clear();
	}

	void Clear()
	{
		_stMailData.Clear();
		_iSystemID = 1000000;
	}

	void AddData(const CZoneMailData &data)
	{
		if (_stMailData.Size() < _stMailData.GetCount())
		{
			_iSystemID++;
			_stMailData.AddOneItem(data);
			_stMailData[_stMailData.m_iUsedCount - 1].SetMailID(_iSystemID);
		}
	}

	void DelData(int index)
	{
		_stMailData.ShiftDelOneItem(index);
	}

	int GetSize() const { return _stMailData.Size(); }
	int FindMail(int id) const
	{
		for(int i = 0; i < _stMailData.Size(); i++)
		{
			if (id == _stMailData[i].GetMailID())
				return i;
		}
		return -1;
	}

	CZoneMailData &GetMail(int index) { return _stMailData[index]; }
public:
	CTArray<CZoneMailData, MAX_PLAYER_MAIL_SYSTEM_MAIL_COUNT>	_stMailData;
	int 			_iSystemID;
};
BEGIN_CODE_CONVERT(CzoneMailSystem)
CODE_CONVERT(_stMailData)
CODE_CONVERT(_iSystemID)
END_CODE_CONVERT(CzoneMailSystem)


class CPlayerCardData : public CTCodeObject
{
public:
    CPlayerCardData()
    {
        Clear();
    }

    void Clear()
    {
		_astAllCards.Clear();
		_astAllDeck.Clear();
		_uiNowDeckId = 0;
		_uiCardBagNum = 0;
		_uiNowBattleDeckId = 0;
    }

	int GetDeckIndex (unsigned int uiDeckId)
	{
		for (int i = 0; i < _astAllDeck.Size(); i++)
		{
			if (uiDeckId == _astAllDeck[i]._uiDeckId)
			{
				return i;
			}
		}

		return -1;
	}

	CSingleDeckData & GetDeck (int iIndex)
	{
		return _astAllDeck[iIndex];
	}

	int SetBattleDeckId (unsigned int uiDeckId)
	{
		int iIndex = GetDeckIndex (uiDeckId);
		if (iIndex < 0)
		{
			return ERROR_DECK_ID_NONE;
		}
		
		_uiNowBattleDeckId = uiDeckId;
		return 0;
	}

	int FindCard(int cardID)
	{
		for(int i = 0; i < _astAllCards.Size(); i++)
		{
			if (cardID == (int)_astAllCards[i].GetCardId())
				return i;
		}
		return -1;
	}

	CSingleCardData &GetCard(int index)
	{
		return _astAllCards[index];
	}

public:
	CTArray<CSingleCardData, ENM_MAX_OWN_CARD> _astAllCards;

	CTArray<CSingleDeckData, ENM_MAX_OWN_DECK> _astAllDeck;

	unsigned int _uiNowDeckId;   //当前分配的牌组ID

	unsigned int _uiCardBagNum;

	unsigned int _uiNowBattleDeckId;   //战斗选择的套牌
};

BEGIN_CODE_CONVERT(CPlayerCardData)
CODE_CONVERT(_astAllCards)
CODE_CONVERT(_astAllDeck)
CODE_CONVERT(_uiNowDeckId)
CODE_CONVERT(_uiCardBagNum)
CODE_CONVERT(_uiNowBattleDeckId)
END_CODE_CONVERT(CPlayerCardData)

//日常任务状态
class CDTaskStatus : public CTCodeObject
{
public:
	CDTaskStatus()
	{
		Clear();
	}

	void Clear()
	{
		_iTaskID = 0;
		_iFinishTimes = 0;
		_iDataID = 0;
		_iTaskStatus = ENUM_TASK_STATUS_NORMAL;
		_iRepeatedTimes = 0;
	}

	int GetTaskID() const { return _iTaskID; }
	int GetFinishTimes() const { return _iFinishTimes; }
	int GetRepeatedTimes() const { return _iRepeatedTimes; }
	int GetDataID() const { return _iDataID; }
	int GetTaskStatus() const { return _iTaskStatus; }

	void SetTaskID(int id) { _iTaskID = id; }
	void SetFinishTimes(int ft) { _iFinishTimes = ft; }
	void SetRepeatedTimes(int rt) { _iRepeatedTimes = rt; }
	void SetDataID(int di) { _iDataID = di; }
	void SetTaskStatus(int ts) { _iTaskStatus = ts; }
public:
	int _iTaskID; //任务ID
	int _iFinishTimes; //已经完成的次数
	int _iRepeatedTimes; //可以重复的次数
	int _iDataID;	//英雄ID或者职业ID 任务的VIP等级
	int _iTaskStatus;
};
BEGIN_CODE_CONVERT(CDTaskStatus)
CODE_CONVERT(_iTaskID)
CODE_CONVERT(_iFinishTimes)
CODE_CONVERT(_iDataID)
CODE_CONVERT(_iTaskStatus)
CODE_CONVERT(_iRepeatedTimes)
END_CODE_CONVERT(CDTaskStatus)

//存放在base数据里面，需要入库
class CDailyTaskUserData : public CTCodeObject
{
public:
	CDailyTaskUserData()
	{
		Clear();
	}

	void Clear()
	{
		_stDailyTaskUserClass.Clear();
		_stDailyCycleTaskUserClass.Clear();
		_stOnceTaskUserClass.Clear();
		_stVIPTaskUserClass.Clear();

		_iLastUpdateTime = 0;
		_iLastModifyTime = 0;
		_iLastCycleUpdateTime = 0;
		_iLastVipUpdateTime = 0;
		_iUserTaskStatus = ENUM_USER_TASK_UNLOAD_CONFIG;
	}

	int AddDailyTask(const CDTaskStatus &status)
	{
		if (_stDailyTaskUserClass.Size() < _stDailyTaskUserClass.GetCount() )
		{
			_stDailyTaskUserClass.AddOneItem(status);
		}
		return 0;
	}

	int AddVIPTask(const CDTaskStatus &status)
	{
		//判断用户是否为VIP
		if (_stVIPTaskUserClass.Size() < _stVIPTaskUserClass.GetCount() )
			_stVIPTaskUserClass.AddOneItem(status);
		return 0;
	}

	void ClearVIPTask()
	{
		_stVIPTaskUserClass.Clear();
	}

	int AddDailyCycleTask(const CDTaskStatus &status)
	{
		if (_stDailyCycleTaskUserClass.Size() < _stDailyCycleTaskUserClass.GetCount() )
			_stDailyCycleTaskUserClass.AddOneItem(status);

		return 0;
	}

	int AddOnceTask(const CDTaskStatus &status)
	{
		if (_stOnceTaskUserClass.Size() < _stOnceTaskUserClass.GetCount() )
			_stOnceTaskUserClass.AddOneItem(status);

		return 0;
	}
public:
	bool IsDailyTaskFull()
	{
		if (_stDailyTaskUserClass.Size() < _stDailyTaskUserClass.GetCount() )
				return false;
		return true;
	}

	bool IsVIPTaskFull()
	{
		if (_stVIPTaskUserClass.Size() < _stVIPTaskUserClass.GetCount() )
				return false;
		return true;
	}
public:
	CTArray<CDTaskStatus, MAX_DAILY_TASK_CONFIG> 	    _stDailyTaskUserClass; //用户当天的任务
	CTArray<CDTaskStatus, MAX_DAILY_CYCLE_TASK_CONFIG>  _stDailyCycleTaskUserClass; //用户当天的循环任务
	CTArray<CDTaskStatus, MAX_ONCE_TASK_CONFIG>	        _stOnceTaskUserClass;
	CTArray<CDTaskStatus, MAX_VIP_TASK_COUNT_CONFIG> 	_stVIPTaskUserClass; //用户当天的VIP任务
	int								_iLastUpdateTime; 		//上一次更新任务的时间
	int 							_iLastModifyTime;		//上一次修改任务的时间
	int								_iLastCycleUpdateTime;  //上一次循环任务更新的时间
	int								_iLastVipUpdateTime;    //上一次VIP任务更新的时间
	int				                _iUserTaskStatus;       //用户任务系统的状态
};
BEGIN_CODE_CONVERT(CDailyTaskUserData)
CODE_CONVERT(_stDailyTaskUserClass)
CODE_CONVERT(_stDailyCycleTaskUserClass)
CODE_CONVERT(_stOnceTaskUserClass)
CODE_CONVERT(_iLastUpdateTime)
CODE_CONVERT(_iLastModifyTime)
CODE_CONVERT(_iUserTaskStatus)
CODE_CONVERT(_stVIPTaskUserClass)
CODE_CONVERT(_iLastCycleUpdateTime)
CODE_CONVERT(_iLastVipUpdateTime)
END_CODE_CONVERT(CDailyTaskUserData)

//好友数据
class CPlayerFriendData : public CTCodeObject
{
public:
	CPlayerFriendData()
	{
		Clear();
	}

	void Clear()
	{
		_astFriendList.Clear();
	}
public:
	bool IsFriend(uint64 uiGID)
	{
		for(int i = 0; i < _astFriendList.Size(); ++i)
		{
			if (uiGID == _astFriendList[i])
			{
				return true;
			}
		}
		return false;
	}
public:
	//返回 ERROR_FRIEND_FULL 增加好友失败 好友列表已满
	//返回 ERROR_FRIEND_EXIST 表示好友已经在列表中
	int AddFriend(uint64 uiGID)
	{
		if (IsFriend(uiGID))
		{
			return ERROR_FRIEND_EXIST;
		}

		if ( _astFriendList.AddOneItem(uiGID) < 0 )
			return ERROR_FRIEND_FULL;

		return 0;
	}
	//返回 1 好友不在列表中
	int DelFriend(uint64 uiGID)
	{
		if (IsFriend(uiGID))
		{
			for(int i = 0; i < _astFriendList.Size(); ++i)
			{
				if (uiGID == _astFriendList[i])
				{
					_astFriendList.ShiftDelOneItem(i);
					return 0;
				}
			}
		}
		return ERROR_FRIEND_NOT_FRIEND;
	}

	int Size()
	{
		return _astFriendList.Size();
	}

	bool IsFull()
	{
		if (_astFriendList.Size() == _astFriendList.GetCount())
			return true;

		return false;
	}

	//需要自己保证索引有效
	uint64 Index(int index)
	{
		return _astFriendList[index];
	}

public:
	//好友系统
	CTArray<uint64, MAX_FRIEND_COUNT> _astFriendList;   //好友列表
};
BEGIN_CODE_CONVERT(CPlayerFriendData)
CODE_CONVERT(_astFriendList)
END_CODE_CONVERT(CPlayerFriendData)

//离线好友发过来的数据
class COfflineFriendData : public CTCodeObject
{
public:
	COfflineFriendData()
	{
		Clear();
	}

	void Clear()
	{
		_iOpt = 0;
		_u64GID = 0;
		_iTime = 0;
	}

public:
	int GetOpt() const { return _iOpt; }
	uint64 GetGID() const { return _u64GID; }
	int GetTime() const { return _iTime; }

	void SetOpt(int opt) { _iOpt = opt; }
	void SetGID(uint64 gid) { _u64GID = gid; }
	void SetTime(int time) { _iTime = time; }
public:
	int _iOpt;
	uint64 _u64GID;
	int _iTime;
};
BEGIN_CODE_CONVERT(COfflineFriendData)
CODE_CONVERT(_iOpt)
CODE_CONVERT(_u64GID)
CODE_CONVERT(_iTime)
END_CODE_CONVERT(COfflineFriendData)

class COfflineFriendMsg : public CTCodeObject
{
public:
	COfflineFriendMsg()
	{
		Clear();
	}

	void Clear()
	{
		_astOfflineFriendDataList.Clear();
	}
public:
	bool IsFull()
	{
		if (_astOfflineFriendDataList.Size() >= _astOfflineFriendDataList.GetCount())
			return true;

		return false;
	}

	int Size()
	{
		return _astOfflineFriendDataList.Size();
	}

	int AddFriendData(const COfflineFriendData &friendData)
	{
		if (IsFull())
			return 1;

		_astOfflineFriendDataList.AddOneItem(friendData);
		return 0;
	}

	COfflineFriendData & Index(int index) { return _astOfflineFriendDataList[index]; }

public:
	CTArray<COfflineFriendData, MAX_OFFLINE_FRIEND_MSG_COUNT> _astOfflineFriendDataList;
};
BEGIN_CODE_CONVERT(COfflineFriendMsg)
CODE_CONVERT(_astOfflineFriendDataList)
END_CODE_CONVERT(COfflineFriendMsg)

class CQualifyingData : public CTCodeObject
{
public:
	CQualifyingData()
	{
		Clear();
	}
public:
	void Clear()
	{
		_iLevel = ENUM_QUALIFYING_MAX_LEVEL;
		_iStar = 0;
		_iKingIntegral = 0;
		_iWinningStread = 0;
		_iKing = 0;
		_iSeasonTime = 0;
	}
public:
	int GetLevel() const { return _iLevel; }
	void SetLevel(int level) { _iLevel = level; }
public:
	int GetStar() const { return _iStar; }
	void SetStar(int star) { _iStar = star; }
public:
	int GetKingIntegral() const { return _iKingIntegral; }
	void SetKingIntegral(int interal) { _iKingIntegral = interal; }
public:
	int GetWinningStread() const { return _iWinningStread; }
	void SetWinningStread(int ws) { _iWinningStread = ws; }
public:
	int GetKing() const { return _iKing; }
	void SetKing(bool k) { _iKing = k; }
public:
	int GetSeasonTime() { return _iSeasonTime; }
	void SetSeasonTime(int time) { _iSeasonTime = time; }
public:
	int		_iLevel; //排位赛等级
	int		_iStar; //用户星星数目
	int 	_iKingIntegral; //王者积分,只有用户达到王者级别才起作用
	int     _iWinningStread; //连胜常数
	int     _iKing; //是否是王者级别
	int    _iSeasonTime; //赛季时间
};
BEGIN_CODE_CONVERT(CQualifyingData)
CODE_CONVERT(_iLevel)
CODE_CONVERT(_iStar)
CODE_CONVERT(_iKingIntegral)
CODE_CONVERT(_iWinningStread)
CODE_CONVERT(_iKing)
CODE_CONVERT(_iSeasonTime)
END_CODE_CONVERT(CQualifyingData)

///////登录奖励/////////////////////////////////////////////////////
class CPlayerLoginReward : public CTCodeObject
{
public:
    CPlayerLoginReward()
    {
        Clear();
    }

	void Clear ()
    {
        _chLoginMask = 0;
        _chRewardMask = 0;
        _iOpenZeroTime = 0;
    }

	virtual ~CPlayerLoginReward()
    {
    }

public:
   char _chLoginMask;
   char _chRewardMask;
   int  _iOpenZeroTime;
};
BEGIN_CODE_CONVERT(CPlayerLoginReward)
CODE_CONVERT(_chLoginMask)
CODE_CONVERT(_chRewardMask)
CODE_CONVERT(_iOpenZeroTime)
END_CODE_CONVERT(CPlayerLoginReward)

///////用户指引数据/////////////////////////////////////////////////////
class CUserGuideData : public CTCodeObject
{
public:
    CUserGuideData()
    {
    	Clear();
    }

	void Clear()
	{
		_szInfo.SetDataLen(0);
	}

public:
    CTLib::CTSizeString<100> _szInfo;
};
BEGIN_CODE_CONVERT(CUserGuideData)
CODE_CONVERT(_szInfo)
END_CODE_CONVERT(CUserGuideData)

class CPlayerVIPInfo : public CTCodeObject
{
public:
	CPlayerVIPInfo()
	{
		_iStatus = 0;
		Clear();
	}

	void Clear()
	{
		_iVipID = 0;
		_iVipTime = 0;
		_iSilver.Clear();
	}
public:
	//别的模块调用判断vip时，请使用CVipMgr中的GetVip()
	int GetVipID() const { return _iVipID; }
	int GetVipTime() const { return _iVipTime; }
	int GetSilver(int NowTime) { return _iSilver.Get(NowTime); }
	int GetStatus() const { return _iStatus; }

	void SetVipID(int id) { _iVipID = id; }
	void SetVipTime(int time) { _iVipTime = time; }
	void SetDefaultSilver(int silver) { _iSilver.SetDefault(silver); }
	void SetSilver(int silver, int nowTime) { _iSilver.Set(silver, nowTime); }
	void SetStatus(int s) { _iStatus = s; }
public:
	int _iVipID;  //vip 级别 ID = 0，不是VIP， = 1 是白银VIP 2 黄金VIP 3无上VIP
	int _iVipTime;  //vip 到期时间
	CDailyReflushInt  _iSilver; //VIP 每日奖励的卡魂数
	int _iStatus; //最后3天提醒一次
};
BEGIN_CODE_CONVERT(CPlayerVIPInfo)
CODE_CONVERT(_iVipID)
CODE_CONVERT(_iVipTime)
CODE_CONVERT(_iSilver)
CODE_CONVERT(_iStatus)
END_CODE_CONVERT(CPlayerVIPInfo)

class CPlayerGrowthFundData : public CTCodeObject
{
public:
	CPlayerGrowthFundData()
	{
		Clear();
	}

	void Clear()
	{
		_iLevel = 0;
		_iStatus = ENUM_GROWTH_FUND_DATA_STATUS_CAN_NOT_RECEIVE;
	}
public:
	void SetLevel(int le) { _iLevel = le; }
	void SetStatus(int st) { _iStatus = st; }
public:
	int GetLevel() const { return _iLevel; }
	int GetStatus() const { return _iStatus; }
public:
	int _iLevel;
	int _iStatus;
};
BEGIN_CODE_CONVERT(CPlayerGrowthFundData)
CODE_CONVERT(_iLevel)
CODE_CONVERT(_iStatus)
END_CODE_CONVERT(CPlayerGrowthFundData)

class CPlayerGrowthFund : public CTCodeObject
{
public:
	CPlayerGrowthFund()
	{
		Clear();
	}

	void Clear()
	{
		_iStatus = ENUM_GROWTH_FUND_STATUS_NOT_YET_PURCHASED;
	}
public:
	void SetStatus(int s) { _iStatus = s; }
	int GetStatus() const { return _iStatus; }

	int Size() const { return _astFundData.Size(); }
	CPlayerGrowthFundData &Index(int in) { return _astFundData[in]; }
public:
	void AddData(const CPlayerGrowthFundData &data)
	{
		if (_astFundData.Size() < _astFundData.GetCount())
			_astFundData.AddOneItem(data);
	}
public:
	int _iStatus;
	CTLib::CTArray<CPlayerGrowthFundData, MAX_GROWTH_FUND_DATA_COUNT> _astFundData;
};
BEGIN_CODE_CONVERT(CPlayerGrowthFund)
CODE_CONVERT(_iStatus)
CODE_CONVERT(_astFundData)
END_CODE_CONVERT(CPlayerGrowthFund)

enum EnumFristRecharge
{
	ENUM_FRIST_RECHARGE_STATUS_NO_RECHARGE = 0,
	ENUM_FRIST_RECHARGE_STATUS_RECHARGE = 1,
	ENUM_FRIST_RECHARGE_STATUS_RECEIVE_REWARD = 2, //接收奖励

	ENUM_FRIST_RECHARGE_ACTION_STATUS_NO_RECHARGE = 0,
	ENUM_FRIST_RECHARGE_ACTION_STATUS_RECHARGE_FIRST = 1,
	ENUM_FRIST_RECHARGE_ACTION_STATUS_RECHARGE_FIRST_REWARD = 2,
	ENUM_FRIST_RECHARGE_ACTION_STATUS_RECHARGE_SECOND = 3,
	ENUM_FRIST_RECHARGE_ACTION_STATUS_RECHARGE_SECOND_REWARD = 4,
	ENUM_FRIST_RECHARGE_ACTION_STATUS_RECHARGE_FINISH = 5,
};

class CPlayerFristRechargeAction : public CTCodeObject
{
public:
	CPlayerFristRechargeAction()
	{

	}

	void Clear()
	{

	}
public:
	int GetStatus() const { return _iStatus; }
	void SetStatus(int st) { _iStatus = st; }
public:
	int _iStatus;
};
BEGIN_CODE_CONVERT(CPlayerFristRechargeAction)
CODE_CONVERT(_iStatus)
END_CODE_CONVERT(CPlayerFristRechargeAction)

class CPlayerFristRecharge : public CTCodeObject
{
public:
	CPlayerFristRecharge()
	{
		Clear();
	}

	void Clear()
	{
		_iStatus = ENUM_FRIST_RECHARGE_STATUS_NO_RECHARGE;
	}
public:
	int GetStatus() const { return _iStatus; }
	void SetStatus(int s) { _iStatus = s; }
public:
	int _iStatus;
};
BEGIN_CODE_CONVERT(CPlayerFristRecharge)
CODE_CONVERT(_iStatus)
END_CODE_CONVERT(CPlayerFristRecharge)

class CPlayerBaseInfo : public CTCodeObject
{
public:
    CPlayerBaseInfo()
    {
        Clear();
    }

    void Clear()
    {
        _cIsMale = 0;
        _shLevel = 1;
        _iGold = 0;
        _iSilver = 0;
        _iNowExp = 0;
        _iPayAmount = 0;
        _stBriefInfo.Clear();
        _stUserDailyTask.Clear();

        _iDefendValidInfo = 2;
        _iLastOfflineTime = 0;
        _iTotalOnlineTime = 0;
        _iTotalOfflineTime = 0;
        _stVipInfo.Clear();
    }

    //加金币
    static int AddGold(int & iNowGold, int iToAddGold)
    {
        if (iToAddGold < 0)
        {
            return ERROR_GOLD_VALID;
        }

        //判断是否会溢出
        if ((iNowGold + iToAddGold) & 0x80000000)
        {
            return ERROR_GOLD_OVER;
        }

        iNowGold += iToAddGold;
        return 0;
    }

    //扣金币
    static int SubGold(int & iNowGold, int iToSubGold)
    {
        if (iToSubGold < 0)
        {
            return ERROR_GOLD_VALID;
        }

        //判断是否会溢出
        if (iNowGold < iToSubGold)
        {
            return ERROR_GOLD_LESS;
        }

        iNowGold -= iToSubGold;
        return 0;
    }

    //加银币
    static int AddSilver(int & iNowSilver, int iToAddSilver)
    {
        if (iToAddSilver < 0)
        {
            return ERROR_SILVER_VALID;
        }

        //判断是否会溢出
        if ((iNowSilver + iToAddSilver) & 0x80000000)
        {
            return ERROR_SILVER_OVER;
        }

        iNowSilver += iToAddSilver;
        return 0;
    }

    //扣银币
    static int SubSilver(int & iNowSilver, int iToSubSilver)
    {
        if (iToSubSilver < 0)
        {
            return ERROR_SILVER_VALID;
        }

        //判断是否会溢出
        if (iNowSilver < iToSubSilver)
        {
            return ERROR_SILVER_LESS;
        }

        iNowSilver -= iToSubSilver;
        return 0;
    }

    //检查int属性值
    static int CheckIntValue(int& iBaseInt, int iChkInt)
    {
        if (iBaseInt < 0)
        {
            return ERROR_BASE_INT_VALID;
        }

        //iChkInt 正数表示加上 负数表示减去
        if (0 == iChkInt)
        {
            return 0;
        }
        else if (iChkInt > 0)
        {
            if ((iBaseInt + iChkInt) & 0x80000000)
            {
                return ERROR_BASE_INT_OVER;
            }
        }
        else if (iChkInt < 0)
        {
            if (iBaseInt + iChkInt < 0)
            {
                return ERROR_BASE_INT_LESS;
            }
        }

        return 0;
    }

    //修改int属性值
    static int ChangeIntValue(int& iBaseInt, int iChgInt)
    {
        int iRet = CheckIntValue(iBaseInt, iChgInt);
        CT_RETURN(iRet);

        iBaseInt += iChgInt;
        return 0;
    }

    //检查int64属性值
    static int CheckInt64Value(int64& i64BaseInt64, int64 i64ChkInt64)
    {
        if (i64BaseInt64 < 0)
        {
            return ERROR_BASE_LL_INT_VALID;
        }

        //i64ChkInt64 正数表示加上 负数表示减去
        if (0 == i64ChkInt64)
        {
            return 0;
        }
        else if (i64ChkInt64 > 0)
        {
            if ((i64BaseInt64 + i64ChkInt64) & 0x8000000000000000)
            {
                return ERROR_BASE_LL_INT_OVER;
            }
        }
        else if (i64ChkInt64 < 0)
        {
            if (i64BaseInt64 + i64ChkInt64 < 0)
            {
                return ERROR_BASE_LL_INT_LESS;
            }
        }

        return 0;
    }

    //修改int64属性值
    static int ChangeInt64Value(int64& i64BaseInt64, int64 i64ChgInt64)
    {
        int iRet = CheckInt64Value(i64BaseInt64, i64ChgInt64);
        CT_RETURN(iRet);

        i64BaseInt64 += i64ChgInt64;
        return 0;
    }

    static void TraceSize()
    {
        CT_TRACE(("CPlayerBaseInfo: %d", sizeof(CPlayerBaseInfo)));
    }
public:
    char                _cIsMale;       //性别 0 女性 非0 男性
    short               _shLevel;       //角色等级
    int                 _iGold;         //金币数量
    int                 _iSilver;       //银币数量
    int                 _iNowExp;       //当前经验
    int                 _iPayAmount;    //充值总数
    CPlayerBriefInfo    _stBriefInfo;   //简要信息

    CDailyTaskUserData  _stUserDailyTask; //用户任务数据

    int                 _iDefendValidInfo;   //用户身份验证状态，1：验证通过， 0：未验证通过, 2: 初始化，从未验证过
    int                 _iLastOfflineTime;   //上一次下线的时间
    int                 _iTotalOnlineTime;   //累计在线时间
    int                 _iTotalOfflineTime;  //累计下线时间

    CPlayerVIPInfo _stVipInfo;
};

BEGIN_CODE_CONVERT(CPlayerBaseInfo)
CODE_CONVERT(_cIsMale)
CODE_CONVERT(_shLevel)
CODE_CONVERT(_iGold)
CODE_CONVERT(_iSilver)
CODE_CONVERT(_iNowExp)
CODE_CONVERT(_iPayAmount)
CODE_CONVERT(_stBriefInfo)
CODE_CONVERT(_stUserDailyTask)
CODE_CONVERT(_iDefendValidInfo)
CODE_CONVERT(_iLastOfflineTime)
CODE_CONVERT(_iTotalOnlineTime)
CODE_CONVERT(_iTotalOfflineTime)
CODE_CONVERT(_stVipInfo)
END_CODE_CONVERT(CPlayerBaseInfo)

/////////////////////////////////////////////////////////////////////////
class CPlayerDetailInfo : public CTCodeObject
{
public:
    CPlayerDetailInfo()
    {
        Clear();
    }

    void Clear()
    {
        _u64GID = 0;
        _stCardData.Clear();
        _stFriendData.Clear();
        _stHeroData.Clear();
        _stLoginReward.Clear();
	    _stOfflineFriendMsg.Clear();
	    _stQualifyingData.Clear();
	    _stArenaData.Clear();
        _stUserGuide.Clear();
        _stGrowthFund.Clear();
        _stFirstRecharge.Clear();
        _stFirstRechargeAction.Clear();
        _stMailSystem.Clear();
    }

public:
    uint64                      _u64GID;        //角色唯一ID
    CPlayerCardData             _stCardData;
    CPlayerFriendData		    _stFriendData;
    CPlayerHeroData		        _stHeroData;
    COfflineFriendMsg		    _stOfflineFriendMsg;
    CQualifyingData		        _stQualifyingData;	//排位赛数据
    CPlayerLoginReward          _stLoginReward;     //登录奖励
    CPlayerArena		        _stArenaData;       //竞技场数据
    CUserGuideData              _stUserGuide;       //用户指引数据

    CPlayerGrowthFund     _stGrowthFund; //成长基金

    CPlayerFristRecharge  _stFirstRecharge; //首冲数据
    CPlayerFristRechargeAction _stFirstRechargeAction; //首充活动数据

    CPlayerMailSystem    _stMailSystem; //邮件系统
};

BEGIN_CODE_CONVERT(CPlayerDetailInfo)
CODE_CONVERT(_u64GID)
CODE_CONVERT(_stCardData)
CODE_CONVERT(_stFriendData)
CODE_CONVERT(_stHeroData)
CODE_CONVERT(_stOfflineFriendMsg)
CODE_CONVERT(_stQualifyingData)
CODE_CONVERT(_stArenaData)
CODE_CONVERT(_stLoginReward)
CODE_CONVERT(_stUserGuide)
CODE_CONVERT(_stGrowthFund)
CODE_CONVERT(_stFirstRecharge)
CODE_CONVERT(_stFirstRechargeAction)
CODE_CONVERT(_stMailSystem)
END_CODE_CONVERT(CPlayerDetailInfo)

/////////////////////////////////////////////////////////////////////////
class CPlayerDBInfo : public CTCodeObject
{
public:
    CPlayerDBInfo()
    {
        Clear();
    }

    void Clear()
    {
        _u64GID = 0;
        _stPlayerBaseInfo.Clear();
        _stPlayerDetailInfo.Clear();
    }

	bool HasHero(unsigned int uiHeroId)
	{
		CPlayerHeroData & stHeroData = _stPlayerDetailInfo._stHeroData;
		for (int i = 0; i < stHeroData._astHeroList.Size(); i++)
		{
			if (stHeroData._astHeroList[i]._uiHeroId == uiHeroId)
			{
				return true;
			}
		}

		return false;
	}

public:
    uint64                  _u64GID;                //角色唯一ID
    CPlayerBaseInfo         _stPlayerBaseInfo;      //角色基础数据
    CPlayerDetailInfo       _stPlayerDetailInfo;    //角色详细数据
};
BEGIN_CODE_CONVERT(CPlayerDBInfo)
CODE_CONVERT(_u64GID)
CODE_CONVERT(_stPlayerBaseInfo)
CODE_CONVERT(_stPlayerDetailInfo)
END_CODE_CONVERT(CPlayerDBInfo)

 //////////////////////////////////////////////////////////////////////////
class CZoneBaseData : public CTCodeObject
{
public:
    CZoneBaseData()
    {
        Clear();
    }
    
    void Clear()
    {
        _iDataID = 0;
        _iZoneOpenTime = 0;
        _iGMTimeOffSet = 0;
    }

public:
    int _iDataID;
    int _iZoneOpenTime;
    int _iGMTimeOffSet;
};
BEGIN_CODE_CONVERT(CZoneBaseData)
CODE_CONVERT(_iDataID)
CODE_CONVERT(_iZoneOpenTime)
CODE_CONVERT(_iGMTimeOffSet)
END_CODE_CONVERT(CZoneBaseData)

//////////////////////////////////////////////////////////////////////////
class CZoneDetailData : public CTCodeObject
{
public:
    CZoneDetailData()
    {
        Clear();
    }

    void Clear()
    {
        _iDataID = 0;
        _stQualifying.Clear();
        _stMailSystem.Clear();
    }

public:
    int _iDataID;
    CZoneQualifyingData _stQualifying;
    CzoneMailSystem		 _stMailSystem;
};
BEGIN_CODE_CONVERT(CZoneDetailData)
CODE_CONVERT(_iDataID)
CODE_CONVERT(_stQualifying)
CODE_CONVERT(_stMailSystem)
END_CODE_CONVERT(CZoneDetailData)

//////////////////////////////////////////////////////////////////////////
class CZoneDBData : public CTCodeObject
{
public:
    CZoneDBData()
    {
        Clear();
    }

    void Clear()
    {
        _stBaseData.Clear();
        _stDetailData.Clear();
    }

public:
    CZoneBaseData _stBaseData;
    CZoneDetailData _stDetailData;
};
BEGIN_CODE_CONVERT(CZoneDBData)
CODE_CONVERT(_stBaseData)
CODE_CONVERT(_stDetailData)
END_CODE_CONVERT(CZoneDBData)

#endif //__COMMH_CLASS_H__

